package com.example.websocketdemo.service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.websocketdemo.config.WebSocketTest;

import java.io.IOException;

public class ElectronicFenceService {

    public void e(String message) throws IOException {
        JSONObject transition = JSON.parseObject(message);
        String value = (String) transition.get("电子围栏区域名称");

        JSONObject jsonObject = new JSONObject();
        JSONObject xinxi = new JSONObject();
        JSONObject xinxi1 = new JSONObject();
        JSONObject xinxi2 = new JSONObject();
        JSONObject xinxi3 = new JSONObject();
        JSONObject xinxi4 = new JSONObject();

        JSONArray Array = new JSONArray();
        jsonObject.put("instruction","dianziweilan");
        if (value.equals("消防泵房")){
            xinxi.put("报警主机名称","001");
            xinxi.put("报警主机编号","001");
            xinxi.put("报警防区","-");
            xinxi.put("设备ID","1001");
            xinxi.put("防区位置","消防泵房");
            xinxi.put("实时数据库位号","-");
            xinxi.put("所属部门","安保");
            xinxi.put("所属责任岗位","-");
            xinxi.put("点位报警优先级","-");
            xinxi.put("issue","false");

            xinxi4.put("报警主机名称","005");
            xinxi4.put("报警主机编号","005");
            xinxi4.put("报警防区","-");
            xinxi4.put("设备ID","1005");
            xinxi4.put("防区位置","消防泵房");
            xinxi4.put("实时数据库位号","-");
            xinxi4.put("所属部门","安保");
            xinxi4.put("所属责任岗位","-");
            xinxi4.put("点位报警优先级","-");
            xinxi4.put("issue","true");

            Array.add(xinxi);
            Array.add(xinxi4);
        }else if (value.equals("泡沫站")){
            xinxi1.put("报警主机名称","002");
            xinxi1.put("报警主机编号","002");
            xinxi1.put("报警防区","-");
            xinxi1.put("设备ID","1002");
            xinxi1.put("防区位置","泡沫站");
            xinxi1.put("实时数据库位号","-");
            xinxi1.put("所属部门","安保");
            xinxi1.put("所属责任岗位","-");
            xinxi1.put("点位报警优先级","-");
            xinxi1.put("issue","false");
            Array.add(xinxi1);
        }else if (value.equals("应急水池站")){
            xinxi2.put("报警主机名称","003");
            xinxi2.put("报警主机编号","003");
            xinxi2.put("报警防区","-");
            xinxi2.put("设备ID","1003");
            xinxi2.put("防区位置","消防泵房");
            xinxi2.put("实时数据库位号","-");
            xinxi2.put("所属部门","应急水池站");
            xinxi2.put("所属责任岗位","-");
            xinxi2.put("点位报警优先级","-");
            xinxi2.put("issue","false");
            Array.add(xinxi2);
        }else if (value.equals("HDPE装置")){
            xinxi3.put("报警主机名称","004");
            xinxi3.put("报警主机编号","004");
            xinxi3.put("报警防区","-");
            xinxi3.put("设备ID","1004");
            xinxi3.put("防区位置","消防泵房");
            xinxi3.put("实时数据库位号","-");
            xinxi3.put("所属部门","HDPE装置");
            xinxi3.put("所属责任岗位","-");
            xinxi3.put("点位报警优先级","-");
            xinxi3.put("issue","true");
            Array.add(xinxi3);
        }
        jsonObject.put("array",Array);
        WebSocketTest.sendInfo(jsonObject.toJSONString(), "connect");
    }
}
